<template>
  <div class="myorder-container">
    <div class="list-group" ref="scrollbars">
      <van-list loading-text="加载中" v-model="loading" :finished="finished"
        :finished-text="listData.length > 0 ? '没有更多了' : ''" @load="initAjaxMethod">
        <div class="match-content" v-for="(item, index) in listData" :key="index">
          <div class="content-img-group-mobile" style="display:none;">
            <div style="position: relative;" class="content-img-group">
            
              <!-- <img :src="item.headerimg" class="content-img"> -->
            </div>
          </div>
          <div class="detail-mobile">
            <div class="detail-info">              
              <span style="margin-left:0.1rem;">{{ item.hoschecknof }}</span>               
            </div>
            <div class="detail-info">              
              <span style="margin-left:0.1rem;">姓名:{{ name }}</span>               
            </div>
            <!-- <div class="detail-info">               
              <span style="margin-left:0.1rem;">电话:{{ item.mobile }}</span>           
            </div> -->
            <div class="detail-info">
          
              <span style="margin-left:0.1rem;">检查号:{{ item.checkNo }}</span>
            </div>
            <div class="detail-info">
              <!-- <span>金额:¥{{item.price}}</span> -->
              <span style="margin-left:0.1rem;">日期：{{item.checkDate  }}   </span>
            </div>
            <div class="bottom-button">
              <!-- <van-button type="info" size="small" @click.stop="$router.push({path:'/workDetail',query:{id:item.id}})">查看详情</van-button> -->
              <van-button type="info" size="small"  @click="gotodetail(item)" >查看详情</van-button>
            </div>
          </div>
        </div>
      </van-list>
      <empty v-if="listData.length == 0"></empty>
    </div>
  </div>
</template>
<script>
import { PullRefresh, List, Icon, Button, Tag, Tab, Tabs,Toast,NavBar,Popup, picker, DatetimePicker,ActionSheet } from 'vant';
import utils from "@/utils/utils";

// import { Form, Field, Toast, NavBar, Button,  Popup, picker, DatetimePicker,ActionSheet } from "vant";
import _ from "lodash";
export default {
  name: "Ordercheckno",
  components: {
    [PullRefresh.name]: PullRefresh, [List.name]: List, [Icon.name]: Icon,
    [Button.name]: Button, [Tab.name]: Tab, [Tag.name]: Tag, [Tabs.name]: Tabs
  },
  data() {
    return {
      refreshDisabled: false,
      showImg: false,
      loading: false,
      active: 0,
      finished: true,
      wxReadyOk: false,
      menuId: 3,
      baseUrl: this.$API.ASSET_IMAGES_URL,
      query: {
        pageIndex: 1,
        pageSize: 10,
       
      },
      total: 0,
      allTotal: 0,
      notTotal: 0,
      doneTotal: 0,
      listData: [],
      certificate: '',
      hoscode:'',
      hosflag:'',
      idCardSuffix:'',
      name:''
    };
  },
  filters: {
    dateFrom(e) {
      if (!e) return '';
      return utils.dateFormat(e, 'cn');
    }
  },
  mounted() {

 
    this.hosflag = this.$route.query.hosflag || "";

    // this.zid=this.$route.query.zid || 1;
    this.checkno=this.$route.query.checkno || "";
    this.hoscode=this.$route.query.hoscode || "";
    this.checkdate=this.$route.query.checkdate || "";

    // name:this.name,idCardSuffix:this.idCardSuffix
    this.name=this.$route.query.name || "";
    this.idCardSuffix=this.$route.query.idCardSuffix || "";
    console.log("103333",this.name);
  
    this.initAjaxMethod();
    // this.totalAjaxMethod();
  },
  methods: {
    menuClick() {
      this.query.pageIndex = 1;
      this.listData = [];
      this.finished = false;
      this.loading = true;
      this.$refs['scrollbars'].scrollTop = 0;
      this.initAjaxMethod();
    },
    //列表加载
    initAjaxMethod() {
    //   const toast = this.$toast.loading('加载中...');
      Toast.loading({ message: "加载中...", forbidClick: true });
      // GET_MEMBER_ORDER 
      //  this.hoscode = this.$route.query.hoscode || "";
        // this.hosflag = this.$route.query.hosflag || "";
        // getMycheckno
        console.log("jiazai")
        this.$http
        .get(this.$API.getAllReport, {
        //   page: this.query.pageIndex,
        //   pageSize: this.query.pageSize,
        //   status: this.active,
           hospitalId: parseInt(this.hoscode),
          hosflag:this.hosflag,
          name:this.name,
          idCardSuffix:this.idCardSuffix,
          nt:new Date().getTime()
        })
        .then((res) => {
            Toast.clear();
        //   toast.clear();
          if (res.code == 200) {
            // this.checktypelist=res.data;
            console.log("sssssssssssss",res.data);

            let list = Array.isArray(res.data) ? res.data : [];
            let isOver = list.length < this.query.pageSize ? true : false;
            this.finished = isOver;
            this.loading = false;
            this.listData = this.query.pageIndex == 1 ? list : [...this.listData, ...list];
            this.total = res.data.total;
            if (!isOver) {
              this.query.pageIndex++;
            }
          }
        });
    },
    totalAjaxMethod(id) {
      this.$http
        .post(this.$API.GET_MEMBER_WORKTOTAL, { signup_id: id })
        .then((res) => {
          if (res.code == 1) {
            this.allTotal = res.all_total || 0;
            this.notTotal = res.not_total || 0;
            this.doneTotal = res.done_total || 0;
          } else {
            this.$notify({ type: 'warning', message: res.msg });
          }
        });
    },

    gotodetail(data) {

        // http://47.120.2.138:8087/#/mobile/checking?zid=9628&checkno=DR1525012&hoscode=193&checkdate=20240604
        this.$router.push({path:'/mobile/checkingzzjnocheck_xcx',query:{zid:this.zid,
            checkno: data.checkNo,hoscode: this.hoscode,checkdate:this.checkDate}});

      
    },
    curriculumIsPlay(data) {
      
      if(data.lnubtype=="needpay"){
        // 围绕之前后台后端判断是否购买
        this.$toast.fail("请先购买课程");return false;
      }else{
        if(data.lnubtype=="lizhi"){
          window.location.href=data.lnub;
        }else{
          this.$router.push({path:'/couPlayback',query:{course_id:data.kcid,kb_id:data.id,isPlay:0}})
        }
         
      }
      return false;
      const toast = this.$toast.loading("加载中...");
      this.$http
        .post(this.$API.GET_CURRICULUM_DETECTION, {
          course_id: data.kcid,
          kb_id: data.id,
        })
        .then((res) => {
          toast.clear();
          if (res.code == 1) {
            if(res.link_url){
                window.location.href=res.link_url;
                return;
            }
            this.$router.push({
              path: "/couPlayback",
              query: { course_id: res.course_id, kb_id: res.kb_id },
            });
          } else {
            this.$toast.fail("请先购买课程");
          }
        });
    },
  },
};
</script>
<style lang="less">
.myorder-container {
  height: 100%;
  position: relative;

  .tabs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;

    .van-tabs__wrap {
      height: 0.88rem;
    }

    .van-tab__text {
      font-size: 0.3rem;
    }
  }

  .list-group {
    height: 100%;
    padding: 0 0.2rem;
  }

  .detail-tags {
    display: flex;
    justify-content: flex-end;

    .van-tag {
      font-size: 0.24rem;
      padding: 0.1rem 0.3rem;
      border-radius: 4px;
      line-height: 0.24rem;
    }
  }

  .match-content {
    padding: 0.2rem;
    color: #3e3a39;
    display: flex;
    box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
    align-items: center;
    margin-top: 0.2rem;
    background: #fff;
    cursor: pointer;
    border-radius: 0.2rem;

    .content-img-group-mobile {
      position: relative;
      align-items: center;
      justify-content: center;

      .content-img-group {
        width: 2rem;
        height: 2rem;
        background: #fff;

        .content-img {
          width: 100%;
          height: 100%;
        }
      }
    }

    .detail-content-mobile {
      font-size: 0.24rem;
      color: #3e3a39;
      padding-top: 0.08rem;
    }

    .detail-mobile {
      width: 60%;
      padding-left: 0.3rem;
      flex-grow: 1;
    }

    .detail-title {
      font-size: 0.28rem;
      color: #333;
      font-weight: bold;
    }

    .detail-info {
      display: flex;
      align-items: center;
      padding-top: 0.16rem;

      span {
        font-size: 0.3rem;
        color: #3e3a39;
      }
    }
  }

  .bottom-button {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-top: 0.2rem;
  }

  .popup-close-group {
    padding: 0.1rem 24%;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
  }

  .popup-close-button {
    height: 0.7rem;
    color: #333;
    line-height: 0.7rem;
    text-align: center;
    font-size: 0.28rem;
  }

  .popup-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .popup-close-header {
    font-size: 0.3rem;
    position: absolute;
    top: 0;
    left: 0;
    padding: 0 0.3rem;
    text-align: right;
    height: 1rem;
    line-height: 1rem;
    width: 100%;
  }
}
</style>